package com.open.capacity.finance.controller;

import java.util.Map;

import com.open.capacity.commons.Result;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.security.access.prepost.PreAuthorize;
import com.open.capacity.finance.entity.AuditModelWarnUser;
import com.open.capacity.finance.service.AuditModelWarnUserService;

import javax.validation.Valid;

import com.open.capacity.commons.PageResult;

/**
 * 模型指标告警
 *
 * @author
 * @email
 * @date 2023-05-17 09:49:11
 */
@RestController
@RequestMapping("auditmodelwarnusers")
@Api(tags = "模型指标告警")
public class AuditModelWarnUserController {

    @Autowired
    private AuditModelWarnUserService auditModelWarnUserService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @PreAuthorize("hasAnyAuthority('audit_model_warn_user:auditmodelwarnuser:list')")
    public PageResult list(@RequestParam Map<String, Object> params) {
        PageResult pageResult = auditModelWarnUserService.pageAll(params);
        return pageResult;
    }


    /**
     * 保存
     */
    @RequestMapping("/saveOrUpdate")
    @PreAuthorize("hasAnyAuthority('audit_model_warn_user:auditmodelwarnuser:save')")
    public Result save(@RequestBody @Valid AuditModelWarnUser auditModelWarnUser, String keyValue) {
        if (StringUtils.isEmpty(keyValue)) {
            auditModelWarnUserService.save(auditModelWarnUser);
        } else {
            auditModelWarnUserService.update(auditModelWarnUser);
        }
        return Result.succeed("操作成功");
    }

}
